import com.ridgesoft.intellibrain.IntelliBrain;
import com.ridgesoft.io.Display;
import com.ridgesoft.robotics.PushButton;
import com.ridgesoft.robotics.sensors.DevantechCMPS03I2C;

/**
 * Initializes the compass as a new thread.
 */
public class Compass implements Runnable{
	private int heading;
	DevantechCMPS03I2C compass;
	
	public Compass() 
	{
	}
	public void init()
	{	
		compass = new DevantechCMPS03I2C(IntelliBrain.getI2CMaster());	
	}
	public String getDirection()
	{
		return compass.direction(heading);
	}
	
	// Sets the heading
	public void setHeading()
	{
		heading = compass.heading();
	}
	
	//returns heading as double
	public double getHeading()
	{
		return heading;
	}
	@Override
	public void run() {
		init();
		Thread.yield();
		while(true)
		{			
			setHeading();
			
		}
		
		
	}
}